﻿using System;
using Manager;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

namespace Studio
{
	// Token: 0x0200055D RID: 1373
	public class ConfigCtrl : MonoBehaviour
	{
		// Token: 0x06002305 RID: 8965 RVA: 0x000D3F00 File Offset: 0x000D2100
		public void Init()
		{
			if (this.isInit)
			{
				return;
			}
			this.soundInfo = new ConfigCtrl.SoundInfo();
			this.buttonColor.image.color = Studio.optionSystem.backColor;
			this.toggleShield.isOn = ConfigData.autoHideObstacle;
			for (int i = 0; i < 6; i++)
			{
				this.sliderSound[i].value = this.soundInfo[i];
			}
			this.buttonColor.onClick.AddListener(new UnityAction(this.OnClickColor));
			this.toggleShield.onValueChanged.AddListener(delegate(bool v)
			{
				ConfigData.autoHideObstacle = v;
				Singleton<Studio>.Instance.cameraCtrl.isConfigVanish = v;
			});
			for (int j = 0; j < 6; j++)
			{
				int no = j;
				this.sliderSound[j].onValueChanged.AddListener(delegate(float v)
				{
					this.OnValueChangedVolume(v, no);
				});
			}
			this.RefreshMixerVolume();
			this.isInit = true;
		}

		// Token: 0x06002306 RID: 8966 RVA: 0x000D4014 File Offset: 0x000D2214
		private void OnClickColor()
		{
			Singleton<Studio>.Instance.colorMenu.updateColorFunc = new UI_ColorInfo.UpdateColor(this.OnValueChangeColor);
			Singleton<Studio>.Instance.colorMenu.SetColor(Studio.optionSystem.backColor, UI_ColorInfo.ControlType.PresetsSample);
			Singleton<Studio>.Instance.colorPaletteCtrl.visible = true;
		}

		// Token: 0x06002307 RID: 8967 RVA: 0x000D4068 File Offset: 0x000D2268
		private void OnValueChangeColor(Color _color)
		{
			Studio.optionSystem.backColor = _color;
			this.buttonColor.image.color = _color;
			Camera.main.backgroundColor = _color;
		}

		// Token: 0x06002308 RID: 8968 RVA: 0x000D4094 File Offset: 0x000D2294
		private void OnValueChangedVolume(float _value, int _idx)
		{
			this.soundInfo[_idx] = _value;
		}

		// Token: 0x06002309 RID: 8969 RVA: 0x000D40A4 File Offset: 0x000D22A4
		private void RefreshMixerVolume()
		{
			MixerVolume.Names[] array = new MixerVolume.Names[]
			{
				MixerVolume.Names.MasterVolume,
				MixerVolume.Names.BGMVolume,
				MixerVolume.Names.SystemSEVolume,
				MixerVolume.Names.GameSEVolume,
				MixerVolume.Names.ENVVolume,
				MixerVolume.Names.PCMVolume
			};
			for (int i = 0; i < 6; i++)
			{
				MixerVolume.Set(Manager.Sound.Mixer, array[i], this.soundInfo[i]);
			}
		}

		// Token: 0x0600230A RID: 8970 RVA: 0x000D40F0 File Offset: 0x000D22F0
		private void Start()
		{
			this.Init();
		}

		// Token: 0x0400240C RID: 9228
		[SerializeField]
		private Button buttonColor;

		// Token: 0x0400240D RID: 9229
		[SerializeField]
		private Toggle toggleShield;

		// Token: 0x0400240E RID: 9230
		[SerializeField]
		private Toggle[] toggleSound;

		// Token: 0x0400240F RID: 9231
		[SerializeField]
		private Slider[] sliderSound;

		// Token: 0x04002410 RID: 9232
		private ConfigCtrl.SoundInfo soundInfo;

		// Token: 0x04002411 RID: 9233
		private bool isInit;

		// Token: 0x0200055E RID: 1374
		private class SoundInfo
		{
			// Token: 0x1700043D RID: 1085
			public float this[int _i]
			{
				get
				{
					switch (_i)
					{
					case 0:
						return ConfigData.volume_master;
					case 1:
						return ConfigData.volume_bgm;
					case 2:
						return ConfigData.volume_system;
					case 3:
						return ConfigData.volume_se;
					case 4:
						return ConfigData.volume_env;
					case 5:
						return ConfigData.volume_voiceAll;
					default:
						return 0f;
					}
				}
				set
				{
					switch (_i)
					{
					case 0:
						ConfigData.volume_master = value;
						MixerVolume.Set(Manager.Sound.Mixer, MixerVolume.Names.MasterVolume, value);
						break;
					case 1:
						ConfigData.volume_bgm = value;
						MixerVolume.Set(Manager.Sound.Mixer, MixerVolume.Names.BGMVolume, value);
						break;
					case 2:
						ConfigData.volume_system = value;
						MixerVolume.Set(Manager.Sound.Mixer, MixerVolume.Names.SystemSEVolume, value);
						break;
					case 3:
						ConfigData.volume_se = value;
						MixerVolume.Set(Manager.Sound.Mixer, MixerVolume.Names.GameSEVolume, value);
						break;
					case 4:
						ConfigData.volume_env = value;
						MixerVolume.Set(Manager.Sound.Mixer, MixerVolume.Names.ENVVolume, value);
						break;
					case 5:
						ConfigData.volume_voiceAll = value;
						MixerVolume.Set(Manager.Sound.Mixer, MixerVolume.Names.PCMVolume, value);
						break;
					}
				}
			}
		}
	}
}
